package com.dispatcher.helper;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

import android.os.Environment;

public class SDHelper {
	// 从文件中读
	public static String getPresentId() {
		if(Environment.getExternalStorageState().equals(Environment.MEDIA_UNMOUNTED)) {
			return null;
		}
		String sdcard = Environment.getExternalStorageDirectory().getAbsolutePath();
		//先判断目录是否存在
		File dir = new File(sdcard + "/dayinxiang");
		if(!dir.exists()) {
			return null;
		}
		//判断文件是否存在
		File file = new File(sdcard + "/dayinxiang" + "/" + "presentid.txt");
		BufferedReader bReader;
		String line = null;
		if(file.exists()) {
			try {
				bReader = new BufferedReader(new FileReader(file));
				line = bReader.readLine();
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			}
			
		}
		return line;
	}
}
